performance slowdown when testing version upgrade 6 --> 16

User d5d3760021

20-07-2016 17:13:34

We're currently using Marvin 6.0.1 in our software, and I'm testing out upgrading to a newer version -- for now I'm testing 16.4.25.


I loaded the new jar files into my application and while it seems to be working, I'm seeing a significant performance degradation. For example, we use your MolPrinter to draw cells in a table. When I scroll through it with the latest Marvin Beans, it's significantly more jerky (enough that my boss said the newer features I'm interested in exposing to users are not worth the slowdown).


I looked in your API for some kind of quality control option, but the only option I found says that only high quality rendering exists as of version 6.4:


https://www.chemaxon.com/jchem/doc/dev/java/api/chemaxon/marvin/MolPrinter.html#setDisplayQuality(int)


Is there some other way that I can get back the rendering performance I had?


 


FYI, I don't think my hardware is too old. I'm on OSX 10.11.5 w/ 16 gb ram (laptop manufactured a year ago). My manager who tested this is on Windows, but I'm not sure what the specs of his machine are.


 


Thanks!


 

ChemAxon cfb2ce1d3d

21-07-2016 09:37:58










nitroamos wrote:

We're currently using Marvin 6.0.1 in our software, and I'm testing out upgrading to a newer version -- for now I'm testing 16.4.25.


I loaded the new jar files into my application and while it seems to be working, I'm seeing a significant performance degradation. For example, we use your MolPrinter to draw cells in a table. When I scroll through it with the latest Marvin Beans, it's significantly more jerky (enough that my boss said the newer features I'm interested in exposing to users are not worth the slowdown).


I looked in your API for some kind of quality control option, but the only option I found says that only high quality rendering exists as of version 6.4:


https://www.chemaxon.com/jchem/doc/dev/java/api/chemaxon/marvin/MolPrinter.html#setDisplayQuality(int)


Is there some other way that I can get back the rendering performance I had?


 


FYI, I don't think my hardware is too old. I'm on OSX 10.11.5 w/ 16 gb ram (laptop manufactured a year ago). My manager who tested this is on Windows, but I'm not sure what the specs of his machine are.


 


Thanks!


 



If you are to upgrade why not try the latest? A lot of thing has changed under the hood that might have resolved your issue too. 


 


Kind regards


Zsolt

User d5d3760021

21-07-2016 12:12:23

Hello Zsolt,


I just verified that the performance issue exists in 16.7.18.0 too. For a bit more context, I'm looking at 2D sketches only in a:


public class StructureCellRenderer extends DefaultTableCellRenderer {
private MolPainter painter;
public void paint(Graphics2D g2)
{        
    painter.paintMolecule(g2, molecule);
}
}


where I've snipped out a but of code and I don't think the painter is configured with any thing other than color scheme, implicit H, abs label=true, grinvVisible = false, etc.


Thanks!

ChemAxon cfb2ce1d3d

21-07-2016 14:07:04










nitroamos wrote:

Hello Zsolt,


I just verified that the performance issue exists in 16.7.18.0 too. For a bit more context, I'm looking at 2D sketches only in a:


public class StructureCellRenderer extends DefaultTableCellRenderer {
private MolPainter painter;
public void paint(Graphics2D g2)
{        
    painter.paintMolecule(g2, molecule);
}
}


where I've snipped out a but of code and I don't think the painter is configured with any thing other than color scheme, implicit H, abs label=true, grinvVisible = false, etc.


Thanks!



 


Your hardware is fine and if the problem still exists in the latest version we have to try something else. 


Since trying to reproduce something similar setup/usage to yours is not trivial, the simplest thing is to profile your app at first. Had you not used VisualVM earlier you may want to install it from here: http://visualvm.java.net/download.html


Start your app with the following JVM setting:


-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5555


(or change the address to whatever appropriate to your system) and start VisualVM. Go to Profile tab and profile CPU and Memory while doing the task in suspect. You can make snapshots to analyze the result and export them so that we can take a look into them too.


Check VisualVM's docu if this description it is not clear.


Let's see if this gives us some hints.


 


Kind regards


Zsolt

User d5d3760021

22-07-2016 03:33:57

Hello Zsolt,


I'll have to confer with my manager to see if it's ok to provide a snapshot publicly, but in the meantime I've attached screencaps of the relevant lines. First, I show the hotspots VisualVM found, and 2nd, I show our entry points into chemaxon drawing routines. One of them is in a method we call "prepareImage" and the other is in a method "paint".


It didn't seem quite as sluggish on my laptop tonight when I was taking these samples... I'll try to take them again on my larger monitor at work tomorrow and see if that makes a difference. Also, maybe tomorrow I'll go revert to Marvin 6 and see how those numbers change...


 


Thanks,


Amos.

ChemAxon cfb2ce1d3d

22-07-2016 07:05:14










nitroamos wrote:

Hello Zsolt,


I'll have to confer with my manager to see if it's ok to provide a snapshot publicly, but in the meantime I've attached screencaps of the relevant lines. First, I show the hotspots VisualVM found, and 2nd, I show our entry points into chemaxon drawing routines. One of them is in a method we call "prepareImage" and the other is in a method "paint".


It didn't seem quite as sluggish on my laptop tonight when I was taking these samples... I'll try to take them again on my larger monitor at work tomorrow and see if that makes a difference. Also, maybe tomorrow I'll go revert to Marvin 6 and see how those numbers change...


 


Thanks,


Amos.



Hello Amos,


Thanks for the pics. Comparing with Marvin 6 is a good idea and suffices for the time being. The whole snapshot file is not yet needed. Please get some Memory snapshots too, so that we can see object instantiations. How many cells and how large molecules are typically in your table?


Kind regards


Zsolt

User d5d3760021

22-07-2016 17:00:34

Hello Zsolt,


Here's a bit more info. As I mentioned, I have 2 methods "paint" and "prepareImage". Here are some timings:


 


Marvin 16.7.18
prepare1955394907 6900 3.24
prepare306143355 3400 5.95
paint1955394907 6900 1.02
paint306143355 3400 1.83

 


Marvin 6.0.1
prepare2078363350 9300 0.04
paint2078363350 9300 0.58
prepare1120947566 4600 0.06
paint1120947566 4600 0.98

 


Where I'm showing the 2 methods followed by a System.identityHashCode for the object which created them, followed by the number of calls (i.e. sample count), followed by System.currentTimeMillis delta averages for the method. There are 3 columns with structures here, one the timers is being used for 2 of the columns.


I tried setting paintercommon.setDispQuality(1); for the old version of marvin, and the timings were similar.


So we can see here the "prepareImage" method used to be "free", and the "paint" method is now twice as expensive.


 


I've got to run to a meeting, I'll try to post more later...


 


Thanks,


Amos.

User d5d3760021

22-07-2016 17:57:04

I've attached the profile view of hotspots with Marvin 6.


I should mention that as far as I can tell, everything is fitting in the heap.


Molecules in this benchmark are molecular weight 100-250, all organics. The list has 4200 rows, but ~11 are visible at a time. I'm also displaying 2 columns each with fragments from the main molecule.


Here's some code from the class:


private MolPainter painter;
private MolPainterCommon paintercommon;
private MolPrinter molPrinter = new MolPrinter();
protected Molecule molecule;

 


 


    /**
     * Prepares MolPainter internals to display the current molecule
     * within the panel region.
     * @param size
     */
    private void prepareImage(Dimension size)
    {
    long t0 = System.currentTimeMillis();
        int molWidth = size.width-2*gap;
        if (molWidth < 0) {
        molWidth = 0;
        }        
int molHeight = size.height-2*gap;
if (molHeight < 0) {
molHeight = 0;
}
Dimension molSize = new Dimension(molWidth, molHeight);
        setPreferredFontSize(molWidth);
        MDocument mDoc = new MDocument(molecule);
        molPrinter.setDoc(mDoc);
        double scale = molPrinter.maxScale(molSize);
        painter.setScale(scale);
        painter.setBoundsFor(molecule);
        //painter.setBoundsFor(molecule,false,false);
        painter.setScreen(molSize);
        painter.setCentralized(true);
    prepTimes.add(System.currentTimeMillis()-t0);
    }

 


 


    /**
     * Repaint the molecule on the panel.
     * Highlights atom selections and marks stored atom selections
     * @param g
     */
    public void paint(Graphics g)
    {
    long t0 = System.currentTimeMillis();
    super.paint(g);
    Graphics2D g2 = (Graphics2D)g;
     if (isFocusRow) {
    g2.setColor(CompoundDisplayConstants.defaultFocusCellBackgroundColor);
    } else if (isSelected){
    g2.setColor(CompoundDisplayConstants.defaultCellHighlightColor);
    } else {
    g2.setColor(Color.WHITE);
    }
    //Finish paint
    paint(g2);
    paintTimes.add(System.currentTimeMillis()-t0);
    }

    /**
     * Repaint the molecule on the panel.
     * Highlights atom selections and marks stored atom selections
     * @param g
     */
public void paint(Graphics2D g2)
    {        
    // update our settings for each paint since we are NO LONGER a display listener...
        CompoundDisplayModel displayModel = listModel.getDisplayModel();
paintercommon.setRendering(displayModel.getRendering());
        paintercommon.setColorScheme(displayModel.getColorScheme());
        paintercommon.setImplicitH(displayModel.getHydrogenDisplay());
    
    //Fill background, then draw structure
    g2.fillRect(0,0,this.getWidth(), this.getHeight());
    painter.setBackground(g2.getColor());
    painter.paintMolecule(g2, molecule); //Paint molecule    
    }

I tried not displaying the Absolute stereo label, but that didn't make much difference.


 


Note that there was an API change for painter.setBoundsFor between the two versions, but that seems inconsequential for this.


 


Any suggestions?


 


Thanks!


Amos.




 



ChemAxon cfb2ce1d3d

28-07-2016 12:53:40










nitroamos wrote:

Hello Zsolt,


Here's a bit more info. As I mentioned, I have 2 methods "paint" and "prepareImage". Here are some timings:


...



 


Hello Amos,


My apologies for the delay.


I observed a bit late that you are using MolPainter which is not in the public API. I strongly advise to look some alternative that realy is. Internal classes can be implemented with assumptions that are not for the public use and addressed correctly only by public classes. 


I attached Java source class to give an example how to create tabular view with the public API. I kindly ask you to take a look at it if it might work for you and check with your data file how it performs.


Kind regards


Zsolt


ui.: Run the class with the path of file of your molecules. Beware of rudimentary code, no checks whatsoever...

User d5d3760021

29-07-2016 10:20:07

Hello Zsolt,


Yes, we're using internal API, although I'm not sure why (I'm not the original author):


import chemaxon.marvin.paint.internal.MolPainter;
import chemaxon.marvin.paint.internal.MolPainterCommon;

Would it be performant to feed your TableSupport only one molecule and embed it in a DefaultTableCellRenderer? We are using a Jide CellStyleTable, derived from a JTable.


Thanks!


Amos.

ChemAxon cfb2ce1d3d

29-07-2016 13:13:07










nitroamos wrote:

Hello Zsolt,


Yes, we're using internal API, although I'm not sure why (I'm not the original author):


import chemaxon.marvin.paint.internal.MolPainter;
import chemaxon.marvin.paint.internal.MolPainterCommon;

Would it be performant to feed your TableSupport only one molecule and embed it in a DefaultTableCellRenderer? We are using a Jide CellStyleTable, derived from a JTable.


Thanks!


Amos.



 


Hello Amos,


Frankly, I do not know. I also do not know the rationale behind giving table support this way in Marvin. Please give it a try and let's see how it behaves. 


 


Kind regards


Zsolt

User d5d3760021

29-07-2016 13:24:45

Just to be sure I understand the suggestion before I commit to trying+benchmarking it -- you don't think there's another approach w/ marvin beans public API that would be faster?


 


Also, another necessary feature is that different places in the GUI for displaying compounds need to have their formatting isolated. e.g. i have a table with structures, that's what this forum post is about, but in other places we use different formatting. When I was playing with the newer version of marvin, I was seeing that formatting (e.g.          opts.setMolNameShown(true);) was undesirably being used in multiple places. I haven't looked into this because I assume that's a configuration issue and performance is more important here, but I just wanted to mention it in case it's unavoidable w/ the updated version of marvin...

User d5d3760021

29-07-2016 19:11:41

I just tested this using 16.4.11:


mview 6000compounds.sdf

and it's hard to tell how fast it's redrawing because as if scroll too fast the structure column will be white until a few milliseconds after i stop scrolling. is there a way to turn off that pause? Is it likely that using TableSupport/MViewPane in my code will draw structures faster than mview? 


If I view that same list within our software using marvin beans 6.0.1 and the internal API, redrawing is instantaneous no matter how fast I scroll.


Unfortunately, my employer's firewall is preventing me from downloading marvin beans for version 6.0.1 to compare performance with mview directly. I submitted a request for access to your URL, so I'll have to wait.

User d5d3760021

29-07-2016 20:34:25

I was able to download marvin 6 and tried mview, and it has the same performance concerns I have with the newer version of marvin. From this I'm guessing the original author of our code turned to your internal API to get performance.


Another comment -- if I switch to matrix view, I don't have scrolling issues like with spreasheet view, but it's definitely sluggish in mview.

ChemAxon f052bdfe3c

30-08-2016 15:14:43

Dear nitroamos,


I am afraid that we cannot solve this problem in the near future. I have made a task in our issue tracking system, and based on our plans we would like to improve speed  in Q4 this year. This problem fits to this plans.


Best regards,


Efi

User d5d3760021

30-08-2016 15:24:40

Hello Efi,


Ok, thank you for getting back to me on this.


Since this issue affects several of our highest profile apps, I think we need to hold off on updating our marvin version until then. FYI, the app I'm working on also requires resolution of:


https://www.chemaxon.com/forum/viewpost66520.html#66520


in order to update.


 


Thank you,


Amos.

User d5d3760021

24-01-2017 14:53:15

Hello Efi,


Any update on this issue?


Thanks,


Amos.

ChemAxon cfb2ce1d3d

26-01-2017 08:52:23










nitroamos wrote:

Hello Efi,


Ok, thank you for getting back to me on this.


Since this issue affects several of our highest profile apps, I think we need to hold off on updating our marvin version until then. FYI, the app I'm working on also requires resolution of:


https://www.chemaxon.com/forum/viewpost66520.html#66520


in order to update.


 


Thank you,


Amos.



Hello Amos,


We still could not get to this preformance issue, but it is not too far, I just can't tell you exact time frame.


The other issue (reaction plus sign) is already fixed, I checked with the current version to be certain. 


 


Kind regards


Zsolt